﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Naruto.TaskManagement.Infrastructure.Email;
using Naruto.TaskManagement.Infrastructure.Interface;
using Naruto.TaskManagement.Infrastructure.Options;
using System;
using System.Collections.Generic;
using System.Text;

namespace Naruto.TaskManagement.Infrastructure.DependencyInjection
{
    public static class EmailDependencyInjection
    {
        /// <summary>
        /// 注入邮件服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddEmail(this IServiceCollection services, IConfiguration configuration)
        {
            services.Configure<EmailOptions>(configuration);
            services.AddSingleton<IEmail, EmailKit>();
            return services;
        }
        /// <summary>
        /// 注入邮件服务
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public static IServiceCollection AddEmail(this IServiceCollection services, Action<EmailOptions> configuration)
        {
            services.Configure(configuration);
            services.AddSingleton<IEmail, EmailKit>();
            return services;
        }
    }
}
